package util {
	import flare.data.DataSet;
	import flare.data.converters.GraphMLConverter;
	import flare.vis.Visualization;
	import flare.vis.data.Data;
	import flare.vis.data.NodeSprite;
	
	import flash.filters.GlowFilter;
	
	public class GraphMLUtil {
		public static function initDataWithGraphMLXML(xml:XML, vis:Visualization, highlightRoot:Boolean=true):void {
			var dataSet:DataSet = new GraphMLConverter().parse(xml);
			vis.data = Data.fromDataSet(dataSet);
			for (var j:int=0; j<vis.data.nodes.length; ++j) {
				vis.data.nodes[j].data.label = String(j);
				vis.data.nodes[j].buttonMode = true;
			}
			vis.data.nodes.sortBy("depth");
			for each (var node:NodeSprite in vis.data.nodes) {
				if (node.data.self == true) {
					vis.data.root = node;
					if (highlightRoot) vis.data.root.filters = [new GlowFilter(0xff0000, 0.5, 15, 15)];
					break;
				}
			}
			
		}
	}
}
